import {createStore, applyMiddleware, compose } from "redux";
import createSagaMiddleware from 'redux-saga'

import reducer from './reducer';
import sagas from './sagas';

const sagaMiddleware = createSagaMiddleware()


const composeEnhancers =
    typeof window === 'object' &&
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
        window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
            // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
        }) : compose;

const enhancer = composeEnhancers(applyMiddleware(sagaMiddleware));


// store是惟一的, 只有store才能改变自己的内容

// store拿到reducer返回的信息,然后store对自己进行更新

const store = createStore(reducer, enhancer);

sagaMiddleware.run(sagas);

export default store;